/*
 * Copyright (c) 2008, Xiong Yingfei, the University of Tokyo
 * All rights reserved.
 */
package ac.jp.u_tokyo.SyncLib.language;

import java.io.IOException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

public class ArrayConst extends Const
{

	private static List<Const> _inners= new LinkedList<Const>();
	public ArrayConst(int line)
	{
		super(line);
	}
	
	public void addInner(Const inner) {
		_inners.add(inner);
	}

	@Override
	public void write(Appendable sb, ConstMapper constMap)
			throws ReferenceNotFoundException, IOException
	{
		sb.append("(new Object[]{");
		Iterator<Const> i = _inners.iterator();
		if (i.hasNext()) {
			i.next().write(sb, constMap);
		}
		while(i.hasNext()) {
			sb.append(',');
			i.next().write(sb, constMap);
		}
		sb.append("})");
	}

}
